import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  saveScrollPosition: true,
  base: __dirname,
  routes: [
    {
      path: '/',
      name: '首页',
      title: '首页',
      component: resolve => require(['./pages/home/index'], resolve)
    },
    {
      path: '/home/:userName/',
      name: 'home',
      title: '首页',
      component: resolve => require(['./pages/home/index'], resolve),
      children: [
        {
          path: 'module_check',
          name: 'module_check',
          meta: {
            title: '模块审核'
          },
          component: resolve => require(['./pages/lmgl/module/check'], resolve)
        }
      ]
    }
  ]
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '营销管理平台'
  next()
})

export default router
